/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servointerpreter;

import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;

class TCPClient {

    public static void start(String ip, int port) throws Exception {
        String sentence;
        String modifiedSentence;
        BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
        Socket clientSocket = new Socket(ip, port);
        DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
        BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

        //Lese die Kommandos ein
        while (true) {
            sentence = inFromUser.readLine();
            if (sentence.equals("c"))
                break;
            outToServer.writeBytes(sentence + '\n');

            modifiedSentence = inFromServer.readLine();
            System.out.println("FROM SERVER: " + modifiedSentence);
        }
        clientSocket.close();
    }
}